<!--
Description :開窗料號挑選
 -->
<%@page contentType="text/html; charset=UTF-8" language="java" import="java.util.*"%>
<%@page import="com.pub.database.*"%>
<%@page import="com.pub.tools.*"%>

<jsp:useBean id="webFunction" scope="request" class="com.pub.web.WebFunction"/>

<!-- 以下為DataView 共用設定 -->
<jsp:useBean id="DataViewForm" scope="request" class="com.pub.database.DataViewForm"/>
<jsp:setProperty name="DataViewForm" property="submitMethod" value="POST"/>
<jsp:setProperty name="DataViewForm" property="pageRowCount" value="10"/>
<jsp:setProperty name="DataViewForm" property="nowPageNum"/>
<jsp:setProperty name="DataViewForm" property="dataViewAction"/>
<jsp:setProperty name="DataViewForm" property="filterCol"/>
<jsp:setProperty name="DataViewForm" property="filterValue"/>
<jsp:setProperty name="DataViewForm" property="dvOrderByFields"/>
<jsp:setProperty name="DataViewForm" property="dvOrderBySeq"/>

<!-- DataView 設定結束 -->
<%

  webFunction.setPortal_to_session(request); //set session from portal
  if (session.getAttribute("u_id") == null) {
    session.setAttribute("path", String.valueOf(request.getRequestURI()));
    session.setAttribute("param", null);
    response.sendRedirect("login.jsp?prg_no=find_part_no.jsp");
    return;
  }

  String strDataViewHtml = null;
  String find_part_no = null;
  DataView DataView=null;


  String db_alias = request.getParameter("db_alias")!=null ? request.getParameter("db_alias"):"WORKFLOW_P";
  //String db_alias = "WORKFLOW_P";
  if(db_alias.equals("")){return;}
  try{
      find_part_no = request.getParameter("find_part_no")!=null ? request.getParameter("find_part_no").toString() : "";
      StringBuffer stbSQL = new   StringBuffer();
      StringBuffer stbCondition = new StringBuffer();
      StringBuffer stbPageActionURI = new StringBuffer("find_part_no.jsp");
      stbPageActionURI.append("?find_part_no=");
      stbPageActionURI.append(find_part_no);
      stbPageActionURI.append("&db_alias=");
      stbPageActionURI.append(db_alias);

      if(find_part_no!=null && !find_part_no.equals("")){
        stbCondition.append("UPPER(item_2nd) like UPPER('%");
        stbCondition.append(find_part_no);
        stbCondition.append("%')");
      }

      DataViewForm.setFieldsList("rownum,item_2nd,item_2nd_desc");
      DataViewForm.setTablesList("wkf_item_master");
      DataViewForm.setSQLCondition(stbCondition.toString());
      DataViewForm.setOrderByFields("item_2nd");
      DataViewForm.setOrderBySeq("asc");
      DataViewForm.setGroupBy(null);
      DataViewForm.setHaving(null);

      boolean blnDebug = false;
      String strColRelation[][] = new String[3][];
      strColRelation[0] = new String[5];
      strColRelation[1] = new String[5];
      strColRelation[2] = new String[5];
      //strColRelation[3] = new String[3];

      strColRelation[0][0] = "'SEL'";
      strColRelation[0][1] = "INPUT";
      strColRelation[0][2] = "WIDTH='10%' ALIGN=\"CENTER\"";
      strColRelation[0][3] = "<input type='radio' CLASS='button b_normal' name='sel'  onclick=\"javascript:retVal(%sn%);\" value=";
      strColRelation[0][4] = "1";

      strColRelation[1][0] = "'料品代碼'";
      strColRelation[1][1] = "INPUT";
      strColRelation[1][2] = " nowrap WIDTH=\"20%\"";
      strColRelation[1][3] = "<input type=\"text\" name=\"part_no%sn%\" class=\"input_noborder\" value=";
      strColRelation[1][4] = "1";

      strColRelation[2][0] = "'料號說明'";
      strColRelation[2][1] = "INPUT";
      strColRelation[2][2] = "nowrap width=\"75%\"";
      strColRelation[2][3] = "<input type=\"text\" name=\"part_desc%sn%\" class=\"input_noborder\" value=";
      strColRelation[2][4] = "2";
/*
      strColRelation[3][0]="'倉別'";
      strColRelation[3][1]="0";
      strColRelation[3][2]="NOWRAP WIDTH='10%' ALIGN=\"CENTER\"";
*/


      DataViewForm.setColRelation(strColRelation);//將欄位相關設定殖入ActionForm

      DataViewForm.setJumpPageButtonShow(false);   //是否要秀出上下頁按鈕
      DataViewForm.setPageBtnOnTop(false);         //將button and rows info 秀在頂端
      DataViewForm.setPageBtnOnButtom(true);      //將button and rows info 秀在底端
      DataViewForm.setFilterShow(false);           //是否要秀出過濾選擇欄位
      DataViewForm.setJumpPageShow(true);         //是否要秀出跳頁下拉式選單
      DataViewForm.setRowsInfoShow(true);         //是否要秀出筆數資訊
      DataViewForm.setRowPageShow(false);          //是否要秀出每頁筆數控制欄
      DataViewForm.setExcelShow(false);           //是否要秀出轉Excel button
      DataViewForm.setOrderEnable(false);          //是否要提供排序點選功能
      DataViewForm.setShowHeaderWhenNoData(true);//當DataView無資料時是否要秀Header

      DataViewForm.setTableDataTrHtml("id='tr%sn%' name='tr%sn%' onmouseover=\"this.className='td_content_over'\" onmouseout=\"this.className='td_content'\"");
      DataViewForm.setTableHeaderHtml("class='td_head_grid' align='center'");
      //設定上一頁與下一頁按鈕的form action(通常為母頁即本頁)
      DataViewForm.setPageActionURI(stbPageActionURI.toString());
      DataView=new com.pub.database.DataView(db_alias,false,"utf-8","utf-8");


      strDataViewHtml = DataView.getOutputDataView(DataViewForm);
    }//try
catch(Exception e){
  e.printStackTrace();
}finally{
  DataViewForm.setColRelation(null);
  DataViewForm=null;
  DataView=null;
}      %>
<html>
<head>
<title>Part No. List</title>
<LINK HREF="/PUBPAGE/general/workflow.css" REL="STYLESHEET" TYPE="TEXT/CSS">
<script type="text/javascript" language="javascript1.2" src="/PUBPAGE/general/commscript.js" ></script>
<script type="text/javascript" language="javascript1.2">
function retVal(varSN){
  window.returnValue=document.all.item('part_no'+varSN).value;
  window.close();
}
</script>
<base target='_self'/>
</head>
<body>

<form method="POST" action="/PUBPAGE/find_part_no.jsp">
<input type="hidden" name="db_alias" value="<%=db_alias%>">
<table>
<tr>
  <th>料品代號：</th>
  <td><input type="text" name="find_part_no" class="input" size="15" value="<%=find_part_no%>">&nbsp;<input type="submit" value="尋找" class="button b_normal"></td>
</tr>
</table>
</form>
<%=strDataViewHtml==null?"":strDataViewHtml %>

</body>
</html>
